#include<iostream>
#include<string.h>
using namespace std;

void ReplaceFun(char *str)
{
	int NumOfSpace = 0 ,newLength,i=0;
	int len=strlen(str);
	for(i=0;i<len;i++)
	{
		if(str[i]==' ')  NumOfSpace++;
	}
	newLength=len+2*NumOfSpace;
	str[newLength--]='\0';
	for(i=len-1;i>=0;i--)
	{
		if(str[i]!=' ')  str[newLength--]=str[i];
		else 
		{
			str[newLength--]='0';
			str[newLength--]='2';
			str[newLength--]='%';
		}
	}
}

int main()
{
	char s1[100]="I am the best one!";
	char s2[100]="   he he he   !";
	ReplaceFun(s1);
	ReplaceFun(s2);
	cout<<s1<<endl;
	cout<<s2<<endl;
	return 0;
}

